package net.nshc.kwkim.mycalc.buttonlistener;

import net.nshc.kwkim.mycalc.util.*;
import android.content.*;
import android.view.*;

public class PointButtonClickListener extends ButtonClickListener {
 
    public PointButtonClickListener(Context context) {
        super(context);
    }
    
    @Override
    public void onClick(View v) {
        String contentOfDisplay = editTextInput.getText().toString();
        
        if (DisplayContentAnalyzer.isTheLastCharacterPoint(contentOfDisplay)) {
            return;
        }
        
        else if (DisplayContentAnalyzer.isTheLastCharacterArithmeticOperator(contentOfDisplay)) {
            appendString(editTextInput, "0");
        }
        
        else if (contentOfDisplay.length() == 0) {
            appendString(editTextInput, "0");
        }
        
        else {
            String theLastOperand = DisplayContentAnalyzer.getTheLastOperandFrom(contentOfDisplay);
            if (DisplayContentAnalyzer.isOperandRealNumber(theLastOperand))
                return;
        }
        
        appendString(editTextInput, ".");
    }
}